<template>
	<view>
		<view class="formcard">
			<view class="bodtitle">
				<p><b>{{title}}</b></p>
			</view>
			<view class="bod_cost" v-for="(item,index) in addlist" :key="index">
				<view class="bus">
					<span>{{item.tit}}</span>
				</view>
				<p v-if="item.type == 'number'">{{commonApi.formatAmt(rows[item.val])}}</p>
				<p v-else-if="item.type == 'bfb'">{{rows[item.val]}}%</p>
				<p  v-else>{{rows[item.val]}}</p>
			</view>
			  <!-- 附件插槽 -->
			  <view class="bod_cost" v-if='file.length!=0'>
			  		<view class="bus">
			  			<span>附件</span>
			  		</view>
			  		<p v-for="(item,index) in file" style='color: rgb(19,140,222);'>{{item.fileName}}</p>
			  </view>
			  <slot name="fj"></slot>
		</view>
	</view>
</template>

<script>
	export default {
		props:['addlist','title','isshow','rows','fileNo'],
		data() {
			return {
				file:[]
			}
		},
		created() {
			
			console.log()
			if(!!this.fileNo){
				let _this = this
				const params = {
					billNo:this.fileNo
				}
				_this.$lyRequest.get('/gateway/basedata/mp/dbsap/base/commonFile/queryList.do',
					params
				).then((result) => {
					if (result.success) {
						console.log(result)
						this.file = result.data.rows
					} else {
						console.log('网络出错')
					}
				})
			}else{
				
			}
			
		},
		methods: {
         timeprocessing(startTime,endTime){
			 if(startTime&&startTime){
				return startTime.replace(/-/g,'.').slice(0,10)+'~'+endTime.replace(/-/g,'.').slice(0,10);
			 }
			
		 }
		},
		watch:{
			rows(val){
				if(val){
					val.destination = val.destination=="0"?'境内':'境外';
					val.tripType = val.tripType=="0"?'工作出差':'培训出差';
					val.isCheckHotel = val.isCheckHotel=="0"?'否':'是';
					val.isWithComputer = val.isWithComputer=="0"?'否':'是';
					val.travelDate = this.timeprocessing(val.startDate,val.endDate)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.bod_cost {
		padding: 15rpx 30rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		border-bottom: none;
		font-size: 34rpx;
		span {
			display: inline-block;
			width: 240rpx;
			font-size: 30rpx;
			color: #666666;
		}
		p {
			font-size: 30rpx;
			word-break:break-all;
			display: inline-block;	
			color: #333333;
		}
	}

</style>
